package c1764;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;

/**
 * 连续和
 * 优化枚举算法：
 * 复杂度:O(N^2) N<=1e4
 */
public class F02Square {

    public static void main(String[] args) {//O(n^2)
        long start = System.currentTimeMillis();
        int n = 15000;
        for (int p = 1; p <= n / 2; p++) {
            for (int q = p + 1; q <= n; q++) {
                int s = (q - p + 1) * (p + q) / 2;
                if (s == n) {
                    System.out.println(p + " " + q);
                }
            }
        }
        long end = System.currentTimeMillis();
        System.out.println((end - start) / 1000.0 + " second(s).");
    }


    static Scanner cin = null;

    static {
        try {
            cin = new Scanner(new FileReader(new File("test.in")));
        } catch (FileNotFoundException e) {
            cin = new Scanner(System.in);
        }
    }
}